package com.artlongs.webapp.postman;

import org.apache.commons.lang.ObjectUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

/**
 * Function: 数据通过URL传输
 *
 * @version $Revision$ $Date$
 *          Date: 15-12-23
 *          Time: 下午2:20
 * @author: monda
 * @since 3.0
 */
public class EventSend {

    public static String to(String url) {
        StringBuilder sb = new StringBuilder("");
        BufferedReader in = null;
        try {
            URL tirc = new URL(url);
            in = new BufferedReader(new InputStreamReader(tirc.openStream(), "UTF-8"));
            String res;
            while ((res = in.readLine()) != null) {
                sb.append(res.trim());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return ObjectUtils.toString(sb);
    }
}
